]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
boxpointer: Compute source allocation and work area just once
authorMarco Trevisan (Treviño) <mail@3v1n0.net>
Fri, 8 Mar 2019 20:36:23 +0000 (14:36 -0600)
committerFlorian Müllner <florian.muellner@gmail.com>
Thu, 11 Apr 2019 19:38:17 +0000 (19:38 +0000)
Compute the source actor workarea and allocation when repositioning and keep it
cached so that we've not to calculating it again in _calculateArrowSide.

Since _calculateArrowSide only is called inside _updateFlip that is always
called just after reposition, we can be sure that the computed values are still
correct.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/435

js/ui/boxpointer.js

index 82dbbaf6acf85e29685e58c461af7346aa6720b7..c8e5ceda7c88ccf2f9774f7d5d620ff06eaf3703 100644 (file)
@@ -473,11 +473,15 @@ var BoxPointer = GObject.registerClass({
     _reposition() {
         let sourceActor = this._sourceActor;
         let alignment = this._arrowAlignment;
+        let monitorIndex = Main.layoutManager.findIndexForActor(sourceActor);
+
+        this._sourceAllocation = Shell.util_get_transformed_allocation(sourceActor);
+        this._workArea = Main.layoutManager.getWorkAreaForMonitor(monitorIndex);
 
         // Position correctly relative to the sourceActor
         let sourceNode = sourceActor.get_theme_node();
         let sourceContentBox = sourceNode.get_content_box(sourceActor.get_allocation_box());
-        let sourceAllocation = Shell.util_get_transformed_allocation(sourceActor);
+        let sourceAllocation = this._sourceAllocation;
         let sourceCenterX = sourceAllocation.x1 + sourceContentBox.x1 + (sourceContentBox.x2 - sourceContentBox.x1) * this._sourceAlignment;
         let sourceCenterY = sourceAllocation.y1 + sourceContentBox.y1 + (sourceContentBox.y2 - sourceContentBox.y1) * this._sourceAlignment;
         let [minWidth, minHeight, natWidth, natHeight] = this.get_preferred_size();
@@ -485,8 +489,7 @@ var BoxPointer = GObject.registerClass({
         // We also want to keep it onscreen, and separated from the
         // edge by the same distance as the main part of the box is
         // separated from its sourceActor
-        let monitorIndex = Main.layoutManager.findIndexForActor(sourceActor);
-        let workarea = Main.layoutManager.getWorkAreaForMonitor(monitorIndex);
+        let workarea = this._workArea;
         let themeNode = this.get_theme_node();
         let borderWidth = themeNode.get_length('-arrow-border-width');
         let arrowBase = themeNode.get_length('-arrow-base');
@@ -606,10 +609,9 @@ var BoxPointer = GObject.registerClass({
     }
 
     _calculateArrowSide(arrowSide) {
-        let sourceAllocation = Shell.util_get_transformed_allocation(this._sourceActor);
+        let sourceAllocation = this._sourceAllocation;
         let [minWidth, minHeight, boxWidth, boxHeight] = this.get_preferred_size();
-        let monitorIndex = Main.layoutManager.findIndexForActor(this._sourceActor);
-        let workarea = Main.layoutManager.getWorkAreaForMonitor(monitorIndex);
+        let workarea = this._workArea;
 
         switch (arrowSide) {
         case St.Side.TOP: